/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tabelamodelcolumnmodel.mysql;

import eloma.classe.mysql.Campos;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 * MysqlTabelasTableModel
 *
 * @author Icaro
 */
public class MysqlCamposTableModel extends AbstractTableModel {

    private List<Campos> listCampos;
    private boolean ordenarPorNome = true;

    public MysqlCamposTableModel(List<Campos> listCampos) {
        this.listCampos = listCampos;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Campos campo = listCampos.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return campo.getField();
            case 1:
                return campo.getType();
            case 2:
                return campo.isNul();
            case 3:
                return campo.getKey();
            case 4:
                return campo.isDefaul();
            case 5:
                return campo.getExtra();
        }

        return null;
    }

    @Override
    public int getRowCount() {
        return listCampos.size();
    }

    @Override
    public int getColumnCount() {
        return 2;
    }

    public Campos getValoresString(int rowIndex) {
        return listCampos.get(rowIndex);
    }

    public boolean isOrdenarPorNome() {
        return ordenarPorNome;
    }

    public void setOrdenarPorNome(boolean ordenarPorNome) {
        this.ordenarPorNome = ordenarPorNome;
    }

}
